package com.example.mybatisplus.web.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.model.dto.vo.BedNumber4BuildingsVO;
import com.example.mybatisplus.model.dto.vo.StatsVO;
import com.example.mybatisplus.model.vo.StatisticVO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.mybatisplus.common.JsonResponse;
import com.example.mybatisplus.service.BedService;
import com.example.mybatisplus.model.domain.Bed;

import java.util.List;


/**
 *
 *  前端控制器
 *
 *
 * @author lxp
 * @since 2024-07-16
 * @version v1.0
 */
@RestController
@RequestMapping("/api/bed")
public class BedController {

    @Autowired
    private BedService bedService;

    @GetMapping("spareBed")
    @ResponseBody
    public JsonResponse spareBed(){
        List<StatisticVO> list = bedService.spareBed();
        return JsonResponse.success(list);
    }

    @GetMapping("getBedByBuilding")
    public JsonResponse getBedByBuilding(){
        List<BedNumber4BuildingsVO> list = bedService.getBedByBuilding();
        return JsonResponse.success(list);
    }
    @GetMapping("getBedById")
    public JsonResponse getBedById(){
        List<StatsVO> list =bedService.getBedByID();
        return JsonResponse.success(list);
    }
    @GetMapping("getBedList")
    public JsonResponse pageList(Bed bed, PageDTO dto){
        Page<Bed> page = bedService.pageList(bed,dto);
        return JsonResponse.success(page);
    }

    @GetMapping("getUnusedBedList")
    public JsonResponse getUnusedBedList(Bed bed, PageDTO dto){
        Page<Bed> page = bedService.getUnusedBedList(bed,dto);
        return JsonResponse.success(page);
    }
}

